<template>
	<view class="contnet">
		<view class="box">
			<view class="grid">
				<view @click="scrollToStrategy()">
					<image src="@/static/images/index/dz.png" mode="aspectFill"></image>
					<view class="text">看游记</view>
				</view>
				<view @click="goroutedetails()">
					<image src="@/static/images/index/dingzhi.png" mode="aspectFill">
					</image>
					<view class="text">一键定制</view>
				</view>
				<view @click="gostrategy()">
					<image src="@/static/images/index/lx.png" mode="aspectFill"></image>
					<view class="text">找路线</view>
				</view>
			</view>

			<view class="u-scroll">
				<u-swiper :list="swiperList" keyName="imgUrl" showTitle circular :autoplay="true" radius="5"
					bgColor="#ffffff" :indicator="true" height="400rpx"></u-swiper>
			</view>

			<view class="box-list">
				<view class="title" ref="strategyTitle">
					<!-- <text></text> -->
					<text>游玩攻略</text>
				</view>

				<u-empty v-if="momentlist.length <= 0" mode="list" width="50%" textSize="30"
					icon="http://cdn.uviewui.com/uview/empty/list.png">
				</u-empty>
				<view class="travel">
					<view class="travel-guide" v-for="(item,index) in momentlist" :key="index"
						@click="gomomentDeatil(item.id)">
						<image
							:src="item.images ? $u.fileBaseUrl+ item.images.split(',')[0] :'../static/images/index/1.png' "
							mode="aspectFit"></image>
						<view class="travel-guide-title">
							{{item.title ? item.title :"快去添加标题吧" }}
						</view>
						<view class="travel-guide-bottom">
							<image
								:src="item.avatar ? $u.fileBaseUrl+ item.avatar :'../static/images/me/default-avatar-orange.png' "
								mode="aspectFill"></image>
							<view class="travel-guide-bottom-left">
								<text>{{item.nickname}}</text>
								<view class="travel-guide-bottom-right">
									<text>{{item.createTime}}</text>
									<view class="chat-icon">
										<uni-icons type="chat" size="20" color="#999999"></uni-icons>
										<text>{{item.commentNum == null ? 0 :item.commentNum}}</text>
									</view>
								</view>
							</view>

						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "find",
		props: ['momentlist', 'swiperList'],
		data() {
			return {
				// swiperList: [],
			};
		},
		methods: {
			// 获取游玩攻略标题的位置
			scrollToStrategy() {
				setTimeout(() => {
					const query = uni.createSelectorQuery().in(this);
					query.select('.title').boundingClientRect(data => {
						uni.pageScrollTo({
							scrollTop: data.top - 100,
							duration: 300
						});
					}).exec();
				}, 100); // 延迟100ms
			},
			gomomentDeatil(id) {
				uni.navigateTo({
					url: `/packagesIndex/pages/guideDetails/guideDetails?id=${id}`
				})
			},
			gostrategy() {
				uni.reLaunch({
					url: `/pages/strategy/strategy?type=${2}`
				})
			},
			goroutedetails() {
				uni.navigateTo({
					url: `/packagesIndex/pages/routedetails/routedetails?type=${1}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.contnet {
		width: 100%;
		min-height: 92vh;
		// background-color: #f6f6f6;
		padding-bottom: 100rpx;
		box-sizing: border-box;

		.box {
			padding-top: 198rpx;
			box-sizing: border-box;

			.grid {
				border-radius: 10rpx;
				background-color: rgb(241, 241, 241);
				display: flex;
				justify-content: space-around;
				align-items: center;
				padding: 25rpx;
				margin: 10rpx;
				box-sizing: border-box;

				view {
					flex: 1;
					text-align: center;

					image {
						width: 70rpx;
						height: 70rpx;
					}


				}
			}

			.u-scroll {
				margin: 10rpx;
				padding: 16rpx 8rpx;
				box-sizing: border-box;
				background-color: rgb(241, 241, 241);
				border-radius: 10rpx;
			}


			.box-list {
				margin: 20rpx 10rpx;
				background-color: rgb(241, 241, 241);

				.title {
					display: flex;
					align-items: center;
					// margin: 30rpx 30rpx 0 30rpx;
					padding: 20rpx 20rpx 0 20rpx;
					box-sizing: border-box;

					text {
						font-size: 32rpx;
					}
				}

				.travel {
					display: flex;
					align-items: center;
					justify-content: space-between;
					flex-wrap: wrap;
					padding: 20rpx;
					box-sizing: border-box;

					.travel-guide {
						box-shadow: 0 2rpx 5rpx rgba(0, 0, 0, 0.2);
						width: 330rpx;
						margin: 15rpx 0;
						background-color: #ffffff;
						padding: 10rpx;
						box-sizing: border-box;
						border-radius: 10rpx;

						image {
							width: 320rpx;
							height: 250rpx;
						}

						.travel-guide-title {
							font-size: 28rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
							text-align: center;

						}

						.travel-guide-bottom {
							width: 100%;
							margin: 10rpx 0;
							display: flex;
							align-items: center;
							gap: 10rpx;

							&>image {
								width: 54rpx;
								height: 54rpx;
								vertical-align: middle;
								border-radius: 50%;
								margin-right: 10rpx;
							}

							.travel-guide-bottom-left {
								display: flex;
								flex-direction: column;
								justify-content: center;
								color: #999999;

								text {
									font-size: 20rpx;
									max-width: 180rpx;
									display: block;
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap;
								}


							}

							.travel-guide-bottom-right {
								align-items: center;
								display: flex;
								justify-content: space-between;
								color: #999999;
								font-size: 20rpx;

								

								.chat-icon{
									display: flex;
									align-items: center;
									uni-icons {
										margin-top: 5rpx;
									}
								}
							}
						}
					}
				}

			}

			swiper {
				width: 96%;
				height: 360rpx;
				margin: 4%;

				image {
					width: 97%;
					border-radius: 20rpx;
				}
			}


		}
	}
</style>